<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>去零数组</title>
    <script>
      // 将数组中值为 0 的项去掉，将不为 0 的值存入一个新的数组，生成新的数组
      function filterZeroItem(arr) {
        var newArr = arr.filter((m) => m !== 0);
        console.log("去零新数组：", newArr);
      }
      filterZeroItem([1, 2, 4, 0, 5, 6, 0, 10]); //去零新数组： (6) [1, 2, 4, 5, 6, 10]
    </script>
  </head>
  <body></body>
</html>
